﻿/**********************************************************************
 * @file   OperCSVPostDataImport.h
 * @brief  CSV 后处理数据导入
 * @author liuzhonghua (liuzhonghuaszch@163.com)
 * @date   2025-02-13
 *********************************************************************/

#ifndef __OperCSVPostDataImport_H
#define __OperCSVPostDataImport_H

#include "FITK_Kernel/FITKCore/FITKActionOperator.h"
#include "FITK_Kernel/FITKCore/FITKOperatorRepo.h"
#include "FITK_Kernel/FITKCore/FITKThreadTask.h"

namespace Acoustics
{
    class FITKAcousticsCSVParameterManager;
    class FITKAcousticsSEASubSysManager;
    class FITKJunctionManager;
};

namespace ModelOper
{
    /**
     * @brief  csv结果文件导入
     * @author liuzhonghua (liuzhonghuaszch@163.com)
     * @date   2025-02-13
     */
    class OperCSVPostDataImport :public Core::FITKActionOperator
    {
        Q_OBJECT
    public:

        /**
         * @brief   Construct a new Oper CSV PostData Import object
         * @author  liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-10
         */
        explicit OperCSVPostDataImport() = default;

        /**
         * @brief   Destroy the Oper CSV PostData Import object
         * @author  liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-10
         */
        virtual ~OperCSVPostDataImport() = default;

        /**
         * @brief   执行GUI操作，选择文件对话框
         * @return  bool
         * @author  liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-10
         */
        virtual bool execGUI() override;

        /**
         * @brief   执行业务操作，导入HDF5后处理文件
         * @return  bool
         * @author  liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-10
         */
        virtual bool execProfession() override;

    private:
        /**
         * @brief    导入csv文件操作
         * @return   bool
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-10
         */
        bool importCSVResult();

    private:

        /**
         * @brief   清除数据
         * @author  liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-10
         */
        void clearData();

    };

    /**
     * @brief  导入csv文件线程
     * @author liuzhonghua (liuzhonghuaszch@163.com)
     * @date   2024-11-18
     */
    class ImportCSVFileThread :public Core::FITKThreadTask
    {
        Q_OBJECT;
    public:
        /**
         * @brief Construct a new ImportCSVFileThread object
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-10-23
         */
        explicit ImportCSVFileThread(Core::FITKActionOperator* oper);
        /**
         * @brief Destroy the ImportCSVFileThread object
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-10-23
         */
        virtual ~ImportCSVFileThread() = default;
        /**
         * @brief    设置文件名称
         * @param[i] fileName 
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-13
         */
        void setFileName(QString fileName);
        /**
         * @brief 执行函数
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-10-23
         */
        void run() override;

    protected:
        /**
         * @brief    设置全局频率
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-14
         */
        void setGlobalFrequency();
        /**
         * @brief    读取参数数据
         * @param[i] dataList 
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-11
         */
        void readParameterData(QStringList dataList);
        /**
         * @brief    获取数据对象ID
         * @param[i] name 
         * @param[i] paraType 
         * @return   int
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-14
         */
        int getObjID(QString name, int paraType);

    protected:
        /**
         * @brief  操作器
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-11-22
         */
        Core::FITKActionOperator* _oper{};
        /**
         * @brief  文件
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-02-13
         */
        QString _fileName;
        /**
         * @brief  CSV参数管理器
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-02-14
         */
        Acoustics::FITKAcousticsCSVParameterManager* _csvParaManager{};
        /**
         * @brief 子系统管理器
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-02-14
         */
        Acoustics::FITKAcousticsSEASubSysManager* _seaSubsysMgr{};
        /**
         * @brief  junction管理器
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-02-14
         */
        Acoustics::FITKJunctionManager* _junctionManager{};
    };

    // 按钮注册相关操作
    Register2FITKOperatorRepo(actionCSVResult, OperCSVPostDataImport);
}
#endif // __OperCSVPostDataImport_H
